﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Hongapo_Common;
using System.Data.SqlClient;

namespace Hongapo_Services.Product
{
    public class Product
    {
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from T_Product");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4)
};
            parameters[0].Value = ID;

            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hongapo_Model.Product.Product model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into T_Product(");
            strSql.Append("MemberID,MID,OrderNo,DeliVerName,DeliVerContact,AuditUserID,IPAdd,Title,Summary,InfoDesc,LinkUrl,RealPrice,OldPrice,Isopen,IsPay,Sort,Createdate,Clicks,Favours,Opposes,Grade,GradeClicks,Remark)");
            strSql.Append(" values (");
            strSql.Append("@MemberID,@MID,@OrderNo,@DeliVerName,@DeliVerContact,@AuditUserID,@IPAdd,@Title,@Summary,@InfoDesc,@LinkUrl,@RealPrice,@OldPrice,@Isopen,@IsPay,@Sort,@Createdate,@Clicks,@Favours,@Opposes,@Grade,@GradeClicks,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@MemberID", SqlDbType.Int,4),
					new SqlParameter("@MID", SqlDbType.Int,4),
					new SqlParameter("@OrderNo", SqlDbType.VarChar,20),
					new SqlParameter("@DeliVerName", SqlDbType.VarChar,20),
					new SqlParameter("@DeliVerContact", SqlDbType.VarChar,50),
					new SqlParameter("@AuditUserID", SqlDbType.Int,4),
					new SqlParameter("@IPAdd", SqlDbType.VarChar,50),
					new SqlParameter("@Title", SqlDbType.NVarChar,1000),
					new SqlParameter("@Summary", SqlDbType.NVarChar,500),
					new SqlParameter("@InfoDesc", SqlDbType.NVarChar),
					new SqlParameter("@LinkUrl", SqlDbType.VarChar,200),
					new SqlParameter("@RealPrice", SqlDbType.Money,8),
					new SqlParameter("@OldPrice", SqlDbType.Money,8),
					new SqlParameter("@Isopen", SqlDbType.Int,4),
					new SqlParameter("@IsPay", SqlDbType.Int,4),
					new SqlParameter("@Sort", SqlDbType.Int,4),
					new SqlParameter("@Createdate", SqlDbType.DateTime),
					new SqlParameter("@Clicks", SqlDbType.Int,4),
					new SqlParameter("@Favours", SqlDbType.Int,4),
					new SqlParameter("@Opposes", SqlDbType.Int,4),
					new SqlParameter("@Grade", SqlDbType.Int,4),
					new SqlParameter("@GradeClicks", SqlDbType.Int,4),
					new SqlParameter("@Remark", SqlDbType.NVarChar,1000)};
            parameters[0].Value = model.MemberID;
            parameters[1].Value = model.MID;
            parameters[2].Value = model.OrderNo;
            parameters[3].Value = model.DeliVerName;
            parameters[4].Value = model.DeliVerContact;
            parameters[5].Value = model.AuditUserID;
            parameters[6].Value = model.IPAdd;
            parameters[7].Value = model.Title;
            parameters[8].Value = model.Summary;
            parameters[9].Value = model.InfoDesc;
            parameters[10].Value = model.LinkUrl;
            parameters[11].Value = model.RealPrice;
            parameters[12].Value = model.OldPrice;
            parameters[13].Value = model.Isopen;
            parameters[14].Value = model.IsPay;
            parameters[15].Value = model.Sort;
            parameters[16].Value = model.Createdate;
            parameters[17].Value = model.Clicks;
            parameters[18].Value = model.Favours;
            parameters[19].Value = model.Opposes;
            parameters[20].Value = model.Grade;
            parameters[21].Value = model.GradeClicks;
            parameters[22].Value = model.Remark;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hongapo_Model.Product.Product model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_Product set ");
            strSql.Append("MemberID=@MemberID,");
            strSql.Append("MID=@MID,");
            strSql.Append("OrderNo=@OrderNo,");
            strSql.Append("DeliVerName=@DeliVerName,");
            strSql.Append("DeliVerContact=@DeliVerContact,");
            strSql.Append("AuditUserID=@AuditUserID,");
            strSql.Append("IPAdd=@IPAdd,");
            strSql.Append("Title=@Title,");
            strSql.Append("Summary=@Summary,");
            strSql.Append("InfoDesc=@InfoDesc,");
            strSql.Append("LinkUrl=@LinkUrl,");
            strSql.Append("RealPrice=@RealPrice,");
            strSql.Append("OldPrice=@OldPrice,");
            strSql.Append("Isopen=@Isopen,");
            strSql.Append("IsPay=@IsPay,");
            strSql.Append("Sort=@Sort,");
            strSql.Append("Createdate=@Createdate,");
            strSql.Append("Clicks=@Clicks,");
            strSql.Append("Favours=@Favours,");
            strSql.Append("Opposes=@Opposes,");
            strSql.Append("Grade=@Grade,");
            strSql.Append("GradeClicks=@GradeClicks,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
					new SqlParameter("@MemberID", SqlDbType.Int,4),
					new SqlParameter("@MID", SqlDbType.Int,4),
					new SqlParameter("@OrderNo", SqlDbType.VarChar,20),
					new SqlParameter("@DeliVerName", SqlDbType.VarChar,20),
					new SqlParameter("@DeliVerContact", SqlDbType.VarChar,50),
					new SqlParameter("@AuditUserID", SqlDbType.Int,4),
					new SqlParameter("@IPAdd", SqlDbType.VarChar,50),
					new SqlParameter("@Title", SqlDbType.NVarChar,1000),
					new SqlParameter("@Summary", SqlDbType.NVarChar,500),
					new SqlParameter("@InfoDesc", SqlDbType.NVarChar),
					new SqlParameter("@LinkUrl", SqlDbType.VarChar,200),
					new SqlParameter("@RealPrice", SqlDbType.Money,8),
					new SqlParameter("@OldPrice", SqlDbType.Money,8),
					new SqlParameter("@Isopen", SqlDbType.Int,4),
					new SqlParameter("@IsPay", SqlDbType.Int,4),
					new SqlParameter("@Sort", SqlDbType.Int,4),
					new SqlParameter("@Createdate", SqlDbType.DateTime),
					new SqlParameter("@Clicks", SqlDbType.Int,4),
					new SqlParameter("@Favours", SqlDbType.Int,4),
					new SqlParameter("@Opposes", SqlDbType.Int,4),
					new SqlParameter("@Grade", SqlDbType.Int,4),
					new SqlParameter("@GradeClicks", SqlDbType.Int,4),
					new SqlParameter("@Remark", SqlDbType.NVarChar,1000),
					new SqlParameter("@ID", SqlDbType.Int,4)};
            parameters[0].Value = model.MemberID;
            parameters[1].Value = model.MID;
            parameters[2].Value = model.OrderNo;
            parameters[3].Value = model.DeliVerName;
            parameters[4].Value = model.DeliVerContact;
            parameters[5].Value = model.AuditUserID;
            parameters[6].Value = model.IPAdd;
            parameters[7].Value = model.Title;
            parameters[8].Value = model.Summary;
            parameters[9].Value = model.InfoDesc;
            parameters[10].Value = model.LinkUrl;
            parameters[11].Value = model.RealPrice;
            parameters[12].Value = model.OldPrice;
            parameters[13].Value = model.Isopen;
            parameters[14].Value = model.IsPay;
            parameters[15].Value = model.Sort;
            parameters[16].Value = model.Createdate;
            parameters[17].Value = model.Clicks;
            parameters[18].Value = model.Favours;
            parameters[19].Value = model.Opposes;
            parameters[20].Value = model.Grade;
            parameters[21].Value = model.GradeClicks;
            parameters[22].Value = model.Remark;
            parameters[23].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string orderno)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from T_Product ");
            strSql.Append(" where orderno=@orderno");
            SqlParameter[] parameters = {
					new SqlParameter("@orderno", SqlDbType.VarChar,20)
};
            parameters[0].Value = orderno;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string IDlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from T_Product ");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 根据产品ID得到一个对象实体
        /// </summary>
        public Hongapo_Model.Product.Product GetModel(int ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 * from T_Product ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4)
};
            parameters[0].Value = ID;

            Hongapo_Model.Product.Product model = new Hongapo_Model.Product.Product();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MemberID"] != null && ds.Tables[0].Rows[0]["MemberID"].ToString() != "")
                {
                    model.MemberID = int.Parse(ds.Tables[0].Rows[0]["MemberID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MID"] != null && ds.Tables[0].Rows[0]["MID"].ToString() != "")
                {
                    model.MID = int.Parse(ds.Tables[0].Rows[0]["MID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OrderNo"] != null && ds.Tables[0].Rows[0]["OrderNo"].ToString() != "")
                {
                    model.OrderNo = ds.Tables[0].Rows[0]["OrderNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DeliVerName"] != null && ds.Tables[0].Rows[0]["DeliVerName"].ToString() != "")
                {
                    model.DeliVerName = ds.Tables[0].Rows[0]["DeliVerName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DeliVerContact"] != null && ds.Tables[0].Rows[0]["DeliVerContact"].ToString() != "")
                {
                    model.DeliVerContact = ds.Tables[0].Rows[0]["DeliVerContact"].ToString();
                }
                if (ds.Tables[0].Rows[0]["AuditUserID"] != null && ds.Tables[0].Rows[0]["AuditUserID"].ToString() != "")
                {
                    model.AuditUserID = int.Parse(ds.Tables[0].Rows[0]["AuditUserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IPAdd"] != null && ds.Tables[0].Rows[0]["IPAdd"].ToString() != "")
                {
                    model.IPAdd = ds.Tables[0].Rows[0]["IPAdd"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Title"] != null && ds.Tables[0].Rows[0]["Title"].ToString() != "")
                {
                    model.Title = ds.Tables[0].Rows[0]["Title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Summary"] != null && ds.Tables[0].Rows[0]["Summary"].ToString() != "")
                {
                    model.Summary = ds.Tables[0].Rows[0]["Summary"].ToString();
                }
                if (ds.Tables[0].Rows[0]["InfoDesc"] != null && ds.Tables[0].Rows[0]["InfoDesc"].ToString() != "")
                {
                    model.InfoDesc = ds.Tables[0].Rows[0]["InfoDesc"].ToString();
                }
                if (ds.Tables[0].Rows[0]["LinkUrl"] != null && ds.Tables[0].Rows[0]["LinkUrl"].ToString() != "")
                {
                    model.LinkUrl = ds.Tables[0].Rows[0]["LinkUrl"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RealPrice"] != null && ds.Tables[0].Rows[0]["RealPrice"].ToString() != "")
                {
                    model.RealPrice = decimal.Parse(ds.Tables[0].Rows[0]["RealPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OldPrice"] != null && ds.Tables[0].Rows[0]["OldPrice"].ToString() != "")
                {
                    model.OldPrice = decimal.Parse(ds.Tables[0].Rows[0]["OldPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Isopen"] != null && ds.Tables[0].Rows[0]["Isopen"].ToString() != "")
                {
                    model.Isopen = int.Parse(ds.Tables[0].Rows[0]["Isopen"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsPay"] != null && ds.Tables[0].Rows[0]["IsPay"].ToString() != "")
                {
                    model.IsPay = int.Parse(ds.Tables[0].Rows[0]["IsPay"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Sort"] != null && ds.Tables[0].Rows[0]["Sort"].ToString() != "")
                {
                    model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Createdate"] != null && ds.Tables[0].Rows[0]["Createdate"].ToString() != "")
                {
                    model.Createdate = DateTime.Parse(ds.Tables[0].Rows[0]["Createdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Clicks"] != null && ds.Tables[0].Rows[0]["Clicks"].ToString() != "")
                {
                    model.Clicks = int.Parse(ds.Tables[0].Rows[0]["Clicks"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Favours"] != null && ds.Tables[0].Rows[0]["Favours"].ToString() != "")
                {
                    model.Favours = int.Parse(ds.Tables[0].Rows[0]["Favours"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Opposes"] != null && ds.Tables[0].Rows[0]["Opposes"].ToString() != "")
                {
                    model.Opposes = int.Parse(ds.Tables[0].Rows[0]["Opposes"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Grade"] != null && ds.Tables[0].Rows[0]["Grade"].ToString() != "")
                {
                    model.Grade = int.Parse(ds.Tables[0].Rows[0]["Grade"].ToString());
                }
                if (ds.Tables[0].Rows[0]["GradeClicks"] != null && ds.Tables[0].Rows[0]["GradeClicks"].ToString() != "")
                {
                    model.GradeClicks = int.Parse(ds.Tables[0].Rows[0]["GradeClicks"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 根据产品编号得到一个对象实体
        /// </summary>
        public Hongapo_Model.Product.Product GetModel(string OrderNO)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 * from T_Product ");
            strSql.Append(" where OrderNo=@OrderNO");
            SqlParameter[] parameters = {
					new SqlParameter("@OrderNO", SqlDbType.VarChar,20)};
            parameters[0].Value = OrderNO;

            Hongapo_Model.Product.Product model = new Hongapo_Model.Product.Product();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MemberID"] != null && ds.Tables[0].Rows[0]["MemberID"].ToString() != "")
                {
                    model.MemberID = int.Parse(ds.Tables[0].Rows[0]["MemberID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MID"] != null && ds.Tables[0].Rows[0]["MID"].ToString() != "")
                {
                    model.MID = int.Parse(ds.Tables[0].Rows[0]["MID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OrderNo"] != null && ds.Tables[0].Rows[0]["OrderNo"].ToString() != "")
                {
                    model.OrderNo = ds.Tables[0].Rows[0]["OrderNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DeliVerName"] != null && ds.Tables[0].Rows[0]["DeliVerName"].ToString() != "")
                {
                    model.DeliVerName = ds.Tables[0].Rows[0]["DeliVerName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DeliVerContact"] != null && ds.Tables[0].Rows[0]["DeliVerContact"].ToString() != "")
                {
                    model.DeliVerContact = ds.Tables[0].Rows[0]["DeliVerContact"].ToString();
                }
                if (ds.Tables[0].Rows[0]["AuditUserID"] != null && ds.Tables[0].Rows[0]["AuditUserID"].ToString() != "")
                {
                    model.AuditUserID = int.Parse(ds.Tables[0].Rows[0]["AuditUserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IPAdd"] != null && ds.Tables[0].Rows[0]["IPAdd"].ToString() != "")
                {
                    model.IPAdd = ds.Tables[0].Rows[0]["IPAdd"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Title"] != null && ds.Tables[0].Rows[0]["Title"].ToString() != "")
                {
                    model.Title = ds.Tables[0].Rows[0]["Title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Summary"] != null && ds.Tables[0].Rows[0]["Summary"].ToString() != "")
                {
                    model.Summary = ds.Tables[0].Rows[0]["Summary"].ToString();
                }
                if (ds.Tables[0].Rows[0]["InfoDesc"] != null && ds.Tables[0].Rows[0]["InfoDesc"].ToString() != "")
                {
                    model.InfoDesc = ds.Tables[0].Rows[0]["InfoDesc"].ToString();
                }
                if (ds.Tables[0].Rows[0]["LinkUrl"] != null && ds.Tables[0].Rows[0]["LinkUrl"].ToString() != "")
                {
                    model.LinkUrl = ds.Tables[0].Rows[0]["LinkUrl"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RealPrice"] != null && ds.Tables[0].Rows[0]["RealPrice"].ToString() != "")
                {
                    model.RealPrice = decimal.Parse(ds.Tables[0].Rows[0]["RealPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OldPrice"] != null && ds.Tables[0].Rows[0]["OldPrice"].ToString() != "")
                {
                    model.OldPrice = decimal.Parse(ds.Tables[0].Rows[0]["OldPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Isopen"] != null && ds.Tables[0].Rows[0]["Isopen"].ToString() != "")
                {
                    model.Isopen = int.Parse(ds.Tables[0].Rows[0]["Isopen"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsPay"] != null && ds.Tables[0].Rows[0]["IsPay"].ToString() != "")
                {
                    model.IsPay = int.Parse(ds.Tables[0].Rows[0]["IsPay"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Sort"] != null && ds.Tables[0].Rows[0]["Sort"].ToString() != "")
                {
                    model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Createdate"] != null && ds.Tables[0].Rows[0]["Createdate"].ToString() != "")
                {
                    model.Createdate = DateTime.Parse(ds.Tables[0].Rows[0]["Createdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Clicks"] != null && ds.Tables[0].Rows[0]["Clicks"].ToString() != "")
                {
                    model.Clicks = int.Parse(ds.Tables[0].Rows[0]["Clicks"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Favours"] != null && ds.Tables[0].Rows[0]["Favours"].ToString() != "")
                {
                    model.Favours = int.Parse(ds.Tables[0].Rows[0]["Favours"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Opposes"] != null && ds.Tables[0].Rows[0]["Opposes"].ToString() != "")
                {
                    model.Opposes = int.Parse(ds.Tables[0].Rows[0]["Opposes"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Grade"] != null && ds.Tables[0].Rows[0]["Grade"].ToString() != "")
                {
                    model.Grade = int.Parse(ds.Tables[0].Rows[0]["Grade"].ToString());
                }
                if (ds.Tables[0].Rows[0]["GradeClicks"] != null && ds.Tables[0].Rows[0]["GradeClicks"].ToString() != "")
                {
                    model.GradeClicks = int.Parse(ds.Tables[0].Rows[0]["GradeClicks"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM T_Product ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" * ");
            strSql.Append(" FROM T_Product ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }


        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            SqlParameter[] parameters = {

                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000)
                    };
            parameters[0].Value = PageSize;
            parameters[1].Value = PageIndex;
            parameters[2].Value = strWhere;	
            return DbHelperSQL.RunProcedure("P_ProductListPager",parameters,"ds");
        }
        #endregion  Method

        public bool UpdateIsopen(int id, int isopen,int AuditUser)
        {
            string sql = "update T_Product set Isopen=" + isopen + ",AuditUserID=" + AuditUser + " where ID=" + id + "";
            int rows = DbHelperSQL.ExecuteSql(sql);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 刷新点击
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public bool UpdateClicks(int ID)
        {
            string sql = "update T_Product set Clicks=Clicks+1 where ID=" + ID + "";
            int rows = DbHelperSQL.ExecuteSql(sql);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
